/*
 * EDAS2 - TetraTech, Inc.
 *
 * Distributable under GPL license.
 * See terms of license at gnu.org.
 */
package com.tetratech.edas2.model;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.AssociationOverride;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PostLoad;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Activity generated by hbm2java
 */
@Entity
@Table(name = "ED_ACTIVITY")
public class Activity extends AttributableUpdateEntity
		implements
			java.io.Serializable {

	private Long uid;
	private ThermalPreservative thermalPreservative;
	private ActivityMedia media;
	private HorizontalCollectionMethod horizontalCollectionMethod;
	private ActivityType type;
	private SamplingCollectionEquipment samplingCollectionEquipment;
	private Assemblage assemblage;
	private NetType netType;
	private HorizontalReferenceDatum horizontalReferenceDatum;
	private ContainerType containerType;
	private MonitoringLocation monitoringLocation;
	private ResultType resultType;
	private ToxicityTestType toxicityTestType;
	private Organization organization;
	private RelativeDepth relativeDepth;
	private TimeZone timeZoneOfEndTime;
	private ContainerColor containerColor;
	private TimeZone timeZoneOfStartTime;
	private ActivityMediaSubdivision mediaSubdivision;
	private String id;
	private String comments;
	private Date startDate;
	private Date startTime;
	private Date endDate;
	private Date endTime;
	private String elevationReferenceDatum;
	private BigDecimal latitude;
	private BigDecimal longitude;
	private Integer sourceMapScale;
	private String samplingChemicalPreservative;
	private String samplingCollectionEquipmentComments;
	private String samplingTransportAndStorageProcedures;
	private Integer passCount;
	private String samplingComponentName;
	private Integer samplingComponentPlaceInSeries;
	private Set<Result> results = new HashSet<Result>(0);

	public Activity() {
	}

	public Activity(Long uid, ActivityMedia media, ActivityType type,
			Organization organization, String id, Date startDate) {
		this.uid = uid;
		this.media = media;
		this.type = type;
		this.organization = organization;
		this.id = id;
		this.startDate = startDate;
	}

	@Id
	@Column(name = "ACT_UID", unique = true, nullable = false, precision = 20, scale = 0)
	@GeneratedValue(generator = "ActivitySequence")
	@SequenceGenerator(name = "ActivitySequence", sequenceName = "ACT_SEQ", allocationSize = 1)
	//@NotNull
	public Long getUid() {
		return this.uid;
	}

	public void setUid(Long uid) {
		this.uid = uid;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "THPRSV_UID")
	public ThermalPreservative getThermalPreservative() {
		return this.thermalPreservative;
	}

	public void setThermalPreservative(ThermalPreservative thermalPreservative) {
		this.thermalPreservative = thermalPreservative;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ACMED_UID", nullable = false)
	@NotNull
	public ActivityMedia getMedia() {
		return this.media;
	}

	public void setMedia(ActivityMedia media) {
		this.media = media;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "HCMTH_UID")
	public HorizontalCollectionMethod getHorizontalCollectionMethod() {
		return this.horizontalCollectionMethod;
	}

	public void setHorizontalCollectionMethod(
			HorizontalCollectionMethod horizontalCollectionMethod) {
		this.horizontalCollectionMethod = horizontalCollectionMethod;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ACTYP_UID", nullable = false)
	@NotNull
	public ActivityType getType() {
		return this.type;
	}

	public void setType(ActivityType type) {
		this.type = type;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "SCEQP_UID")
	public SamplingCollectionEquipment getSamplingCollectionEquipment() {
		return this.samplingCollectionEquipment;
	}

	public void setSamplingCollectionEquipment(
			SamplingCollectionEquipment samplingCollectionEquipment) {
		this.samplingCollectionEquipment = samplingCollectionEquipment;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ASMBLG_UID")
	public Assemblage getAssemblage() {
		return this.assemblage;
	}

	public void setAssemblage(Assemblage assemblage) {
		this.assemblage = assemblage;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "NETTYP_UID")
	public NetType getNetType() {
		return this.netType;
	}

	public void setNetType(NetType netType) {
		this.netType = netType;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "HRDAT_UID")
	public HorizontalReferenceDatum getHorizontalReferenceDatum() {
		return this.horizontalReferenceDatum;
	}

	public void setHorizontalReferenceDatum(
			HorizontalReferenceDatum horizontalReferenceDatum) {
		this.horizontalReferenceDatum = horizontalReferenceDatum;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CONTYP_UID")
	public ContainerType getContainerType() {
		return this.containerType;
	}

	public void setContainerType(ContainerType containerType) {
		this.containerType = containerType;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "MLOC_UID")
	public MonitoringLocation getMonitoringLocation() {
		return this.monitoringLocation;
	}

	public void setMonitoringLocation(MonitoringLocation monitoringLocation) {
		this.monitoringLocation = monitoringLocation;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "RES_TYPE_UID")
	public ResultType getResultType() {
		return this.resultType;
	}

	public void setResultType(ResultType resultType) {
		this.resultType = resultType;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TTTYP_UID")
	public ToxicityTestType getToxicityTestType() {
		return this.toxicityTestType;
	}

	public void setToxicityTestType(ToxicityTestType toxicityTestType) {
		this.toxicityTestType = toxicityTestType;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ORG_UID", nullable = false)
	@NotNull
	public Organization getOrganization() {
		return this.organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "RELDPTH_UID")
	public RelativeDepth getRelativeDepth() {
		return this.relativeDepth;
	}

	public void setRelativeDepth(RelativeDepth relativeDepth) {
		this.relativeDepth = relativeDepth;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TMZONE_UID_END_TIME")
	public TimeZone getTimeZoneOfEndTime() {
		return this.timeZoneOfEndTime;
	}

	public void setTimeZoneOfEndTime(TimeZone timeZoneOfEndTime) {
		this.timeZoneOfEndTime = timeZoneOfEndTime;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CONCOL_UID")
	public ContainerColor getContainerColor() {
		return this.containerColor;
	}

	public void setContainerColor(ContainerColor containerColor) {
		this.containerColor = containerColor;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "TMZONE_UID_START_TIME")
	public TimeZone getTimeZoneOfStartTime() {
		return this.timeZoneOfStartTime;
	}

	public void setTimeZoneOfStartTime(TimeZone timeZoneOfStartTime) {
		this.timeZoneOfStartTime = timeZoneOfStartTime;
	}
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "AMSUB_UID")
	public ActivityMediaSubdivision getMediaSubdivision() {
		return this.mediaSubdivision;
	}

	public void setMediaSubdivision(ActivityMediaSubdivision mediaSubdivision) {
		this.mediaSubdivision = mediaSubdivision;
	}

	@Column(name = "ACT_ID", nullable = false, length = 35)
	@NotNull
	@Length(max = 35)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "ACT_COMMENTS", length = 4000)
	@Length(max = 4000)
	public String getComments() {
		return this.comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}
	@Temporal(TemporalType.DATE)
	@Column(name = "ACT_START_DATE", nullable = false, length = 7)
	@NotNull
	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	@Temporal(TemporalType.DATE)
	@Column(name = "ACT_START_TIME", length = 7)
	public Date getStartTime() {
		return this.startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}
	@Temporal(TemporalType.DATE)
	@Column(name = "ACT_END_DATE", length = 7)
	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}
	@Temporal(TemporalType.DATE)
	@Column(name = "ACT_END_TIME", length = 7)
	public Date getEndTime() {
		return this.endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}

	@Column(name = "ACT_DEPTH_ALTITUDE_REF_POINT", length = 125)
	@Length(max = 125)
	public String getElevationReferenceDatum() {
		return this.elevationReferenceDatum;
	}

	public void setElevationReferenceDatum(String elevationReferenceDatum) {
		this.elevationReferenceDatum = elevationReferenceDatum;
	}

	@Column(name = "ACT_LOC_LATITUDE", precision = 22, scale = 0)
	public BigDecimal getLatitude() {
		return this.latitude;
	}

	public void setLatitude(BigDecimal latitude) {
		this.latitude = latitude;
	}

	@Column(name = "ACT_LOC_LONGITUDE", precision = 22, scale = 0)
	public BigDecimal getLongitude() {
		return this.longitude;
	}

	public void setLongitude(BigDecimal longitude) {
		this.longitude = longitude;
	}

	@Column(name = "ACT_LOC_SOURCE_MAP_SCALE", precision = 8, scale = 0)
	public Integer getSourceMapScale() {
		return this.sourceMapScale;
	}

	public void setSourceMapScale(Integer sourceMapScale) {
		this.sourceMapScale = sourceMapScale;
	}

	@Column(name = "ACT_SAM_CHEMICAL_PRESERVATIVE", length = 250)
	@Length(max = 250)
	public String getSamplingChemicalPreservative() {
		return this.samplingChemicalPreservative;
	}

	public void setSamplingChemicalPreservative(
			String samplingChemicalPreservative) {
		this.samplingChemicalPreservative = samplingChemicalPreservative;
	}

	@Column(name = "ACT_SAM_COLLECT_EQUIP_COMMENTS", length = 4000)
	@Length(max = 4000)
	public String getSamplingCollectionEquipmentComments() {
		return this.samplingCollectionEquipmentComments;
	}

	public void setSamplingCollectionEquipmentComments(
			String samplingCollectionEquipmentComments) {
		this.samplingCollectionEquipmentComments = samplingCollectionEquipmentComments;
	}

	@Column(name = "ACT_SAM_TRANSPORT_STORAGE_DESC", length = 250)
	@Length(max = 250)
	public String getSamplingTransportAndStorageProcedures() {
		return this.samplingTransportAndStorageProcedures;
	}

	public void setSamplingTransportAndStorageProcedures(
			String samplingTransportAndStorageProcedures) {
		this.samplingTransportAndStorageProcedures = samplingTransportAndStorageProcedures;
	}

	@Column(name = "ACT_PASS_COUNT", precision = 6, scale = 0)
	public Integer getPassCount() {
		return this.passCount;
	}

	public void setPassCount(Integer passCount) {
		this.passCount = passCount;
	}

	@Column(name = "ACT_SAM_COMPNT_NAME", length = 15)
	@Length(max = 15)
	public String getSamplingComponentName() {
		return this.samplingComponentName;
	}

	public void setSamplingComponentName(String samplingComponentName) {
		this.samplingComponentName = samplingComponentName;
	}

	@Column(name = "ACT_SAM_COMPNT_PLACE_IN_SERIES", precision = 6, scale = 0)
	public Integer getSamplingComponentPlaceInSeries() {
		return this.samplingComponentPlaceInSeries;
	}

	public void setSamplingComponentPlaceInSeries(
			Integer samplingComponentPlaceInSeries) {
		this.samplingComponentPlaceInSeries = samplingComponentPlaceInSeries;
	}
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "activity")
	public Set<Result> getResults() {
		return this.results;
	}

	public void setResults(Set<Result> results) {
		this.results = results;
	}

	// The following is extra code specified in the hbm.xml files

	private SamplingMethod collectionMethod = new SamplingMethod();
	private SamplingMethod preparationMethod = new SamplingMethod();
	private Measurement boatSpeed = new Measurement();
	private Measurement collectionDuration = new Measurement();
	private Measurement currentSpeed = new Measurement();
	private Measurement elevation = new Measurement();
	private Measurement horizontalAccuracy = new Measurement();
	private Measurement lowerElevation = new Measurement();
	private Measurement netMeshSize = new Measurement();
	private Measurement netSurfaceArea = new Measurement();
	private Measurement reachLength = new Measurement();
	private Measurement reachWidth = new Measurement();
	private Measurement upperElevation = new Measurement();

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_BOAT_SPEED"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_BOAT_SPEED"))
	public Measurement getBoatSpeed() {
		return this.boatSpeed;
	}

	public void setBoatSpeed(Measurement boatSpeed) {
		this.boatSpeed = boatSpeed;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_COLLECTION_DURATION"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_COLLECTION_DURATION"))
	public Measurement getCollectionDuration() {
		return this.collectionDuration;
	}

	public void setCollectionDuration(Measurement collectionDuration) {
		this.collectionDuration = collectionDuration;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_CURRENT_SPEED"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_CURRENT_SPEED"))
	public Measurement getCurrentSpeed() {
		return this.currentSpeed;
	}

	public void setCurrentSpeed(Measurement currentSpeed) {
		this.currentSpeed = currentSpeed;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_DEPTH_HEIGHT"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_DEPTH_HEIGHT"))
	public Measurement getElevation() {
		return this.elevation;
	}

	public void setElevation(Measurement elevation) {
		this.elevation = elevation;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_HORIZONTAL_ACCURACY"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_HORIZONTAL_ACCURACY"))
	public Measurement getHorizontalAccuracy() {
		return this.horizontalAccuracy;
	}

	public void setHorizontalAccuracy(Measurement horizontalAccuracy) {
		this.horizontalAccuracy = horizontalAccuracy;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_DEPTH_HEIGHT_BOTTOM"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_DEPTH_HEIGHT_BOTTOM"))
	public Measurement getLowerElevation() {
		return this.lowerElevation;
	}

	public void setLowerElevation(Measurement lowerElevation) {
		this.lowerElevation = lowerElevation;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_NET_MESH_SIZE"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_NET_MESH_SIZE"))
	public Measurement getNetMeshSize() {
		return this.netMeshSize;
	}

	public void setNetMeshSize(Measurement netMeshSize) {
		this.netMeshSize = netMeshSize;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_NET_SURFACE_AREA"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_NET_SURFACE_AREA"))
	public Measurement getNetSurfaceArea() {
		return this.netSurfaceArea;
	}

	public void setNetSurfaceArea(Measurement netSurfaceArea) {
		this.netSurfaceArea = netSurfaceArea;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_REACH_LENGTH"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_REACH_LENGTH"))
	public Measurement getReachLength() {
		return this.reachLength;
	}

	public void setReachLength(Measurement reachLength) {
		this.reachLength = reachLength;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_REACH_WIDTH"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_REACH_WIDTH"))
	public Measurement getReachWidth() {
		return this.reachWidth;
	}

	public void setReachWidth(Measurement reachWidth) {
		this.reachWidth = reachWidth;
	}

	@Embedded
	@AttributeOverride(name = "value", column = @Column(name = "ACT_DEPTH_HEIGHT_TOP"))
	@AssociationOverride(name = "unit", joinColumns = @JoinColumn(name = "MSUNT_UID_DEPTH_HEIGHT_TOP"))
	public Measurement getUpperElevation() {
		return this.upperElevation;
	}

	public void setUpperElevation(Measurement upperElevation) {
		this.upperElevation = upperElevation;
	}

	@Embedded
	@AttributeOverrides({
			@AttributeOverride(name = "context", column = @Column(name = "ACT_SAM_COLLECT_METH_CONTEXT")),
			@AttributeOverride(name = "description", column = @Column(name = "ACT_SAM_COLLECT_METH_DESC")),
			@AttributeOverride(name = "id", column = @Column(name = "ACT_SAM_COLLECT_METH_ID")),
			@AttributeOverride(name = "name", column = @Column(name = "ACT_SAM_COLLECT_METH_NAME")),
			@AttributeOverride(name = "type", column = @Column(name = "ACT_SAM_COLLECT_METH_QUAL_TYPE"))})
	public SamplingMethod getCollectionMethod() {
		return this.collectionMethod;
	}

	public void setCollectionMethod(SamplingMethod collectionMethod) {
		this.collectionMethod = collectionMethod;
	}

	@Embedded
	@AttributeOverrides({
			@AttributeOverride(name = "context", column = @Column(name = "ACT_SAM_PREP_METH_CONTEXT")),
			@AttributeOverride(name = "description", column = @Column(name = "ACT_SAM_PREP_METH_DESC")),
			@AttributeOverride(name = "id", column = @Column(name = "ACT_SAM_PREP_METH_ID")),
			@AttributeOverride(name = "name", column = @Column(name = "ACT_SAM_PREP_METH_NAME")),
			@AttributeOverride(name = "type", column = @Column(name = "ACT_SAM_PREP_METH_QUAL_TYPE"))})
	public SamplingMethod getPreparationMethod() {
		return this.preparationMethod;
	}

	public void setPreparationMethod(SamplingMethod preparationMethod) {
		this.preparationMethod = preparationMethod;
	}

	@PostLoad
	public void afterLoad() {
		if (collectionMethod == null) {
			collectionMethod = new SamplingMethod();
		}

		if (preparationMethod == null) {
			preparationMethod = new SamplingMethod();
		}
	}

	// end of extra code specified in the hbm.xml files

}
